<?=view('admin.common.header')?>
<style>
    .table>tbody>tr>td {vertical-align: middle;}
</style>
<form id="modifyform" action method="post">
<table class="table">
    <tr>
        <td>小区拼音缩写</td>
        <td>
            <input type="text" name="id" class="form-control" value="<?= $plot->id ?>" required="required"/>
        </td>
    </tr>
    <tr>
        <td>小区名称</td>
        <td>
            <input type="text" name="name" class="form-control" value="<?= $plot->name ?>" required="required"/>
        </td>
    </tr>
    <tr>
        <td>所属地区</td>
        <td>
            <select name="area" class="form-control" required="required">
                <?php foreach($area as $val): ?>
                <option value="<?= $val->id?>" <?php if ($plot->area == $val->id): ?>selected="selected"<?php endif; ?>><?= $val->name?></option>
                <?php endforeach; ?>
            </select>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <button class="btn btn-primary form-control eveModify">修　改</button>
        </td>
    </tr>
</table>
    <script>
        $('.eveModify').click(function(){
            var area=$('select[name=area]'), name = $('input[name="name"]').val(), id = $("input[name=id]").val();
            if (area == '<?= $plot->area ?>' && name == '<?= $plot->name ?>' && id == '<?= $plot->id ?>') {
                layer.msg('没有任何改动');
                return false;
            }
            if (id == '') {
                layer.msg('小区拼音缩写不能为空');
                return false;
            }
            if (name == '') {
                layer.msg('小区名称不能为空');
                return false;
            }
            $("#modifyform").ajaxSubmit(function(data){
                layer.msg(data.info);
                if (data.status == 1) {
                    window.parent.location.reload();
                }
            });
            return false;
        })
    </script>
</body>
</html>